package C;

import java.util.Comparator;

class Student implements Comparable<Student> {
        public String name;
        public int age;

        public Student(String name, int age) {
            this.name = name;
            this.age = age;
        }

        @Override
        public String toString() {
            return "Student{" +
                    "name='" + name + '\'' +
                    ", age='" + age + '\'' +
                    '}';
        }

          @Override
          public int compareTo(Student o) {
            return this.age-o.age;
         }
    }
     class AgeComparator implements Comparator<Student> {

         @Override
         public int compare(Student o1, Student o2) {
             return o1.age-o2.age;
         }
     }

    public class C {
        public static void main(String[] args) {

            Student student1 = new Student("zhangsan", 38);
            Student student2 = new Student("lisa", 12);
            AgeComparator ageComparator = new AgeComparator();
            if (ageComparator.compare(student1, student2) > 0) {
                System.out.println("student1>student2");
            } else {
                System.out.println("s1<=s2");
            }

        }
    }
    


